package com.qidianit.task.controller;

import com.qidianit.task.pojo.Project;
import com.qidianit.task.service.ProjectService;
import com.qidianit.task.util.pojo.QdResult;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 戴着假发的程序员
 * @Company 起点编程
 * @Description
 * @Time 2024/9/5 下午 4:45
 */
@RestController
@RequestMapping("/project")
@CrossOrigin
public class ProjectController {
    @Autowired
    private ProjectService projectService;

    @GetMapping("/get")
    public QdResult get(String projectId){
        return projectService.queryById(projectId);
    }
    @PostMapping("/save")
    public QdResult save(@RequestBody Project project){
        return projectService.saveProject(project);
    };
    // 这里没有使用@RequestBody
    @GetMapping("/list")
    public QdResult list(Project project, @RequestParam(defaultValue = "1")int page,@RequestParam(defaultValue = "10")int limit){
        return projectService.selectByPage(project,page,limit);
    }
    @GetMapping("/listDeletes")
    public QdResult listDeletes(Project project, @RequestParam(defaultValue = "1")int page,@RequestParam(defaultValue = "10")int limit){
        return projectService.queryDeletes(project,page,limit);
    }


    @PutMapping("/update")
    public QdResult update(@RequestBody Project project){
        return projectService.updateById(project);
    }
    @PutMapping("/archive")
    public QdResult archive(String projectId){
        return projectService.archiveById(projectId);
    }
    @DeleteMapping("/delete")
    public QdResult delete(String projectId){
        return projectService.deleteById(projectId);
    }
    @DeleteMapping("/deletes")
    public QdResult deletes(String [] projectId){
        return projectService.deletes(projectId);
    }
    @PutMapping("/archives")
    public QdResult archives(String [] projectId){
        return projectService.archives(projectId);
    }
    @PutMapping("/releases")
    public QdResult releases(String [] projectId){
        return projectService.releases(projectId);
    }
    @PutMapping("/re-releases")
    public QdResult reReleases(String [] projectId){
        return projectService.reReleases(projectId);
    }
    @PutMapping("/re-draft")
    public QdResult reDraft(String [] projectId){
        return projectService.reDrafts(projectId);
    }
}
